package com.mk.carcassonne.drawables;

import java.util.HashMap;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

public class BitmapCache
{
	private Context _context;
	private HashMap<Integer, Bitmap> _bitMaps;
	
	public BitmapCache(Context context)
	{
		_context = context;
		_bitMaps = new HashMap<Integer, Bitmap>();
	}
	
	public Bitmap getBitmapForResource(Integer resourceId)
	{
		if(_bitMaps.containsKey(resourceId))
		{
			return _bitMaps.get(resourceId);
		}
		
		Bitmap brickImage = BitmapFactory.decodeResource(_context.getResources(), resourceId);
		if(brickImage != null)
		{
			_bitMaps.put(resourceId, brickImage);
		}
		
		return brickImage;
	}
}
